import 'package:flutter/material.dart';

/// 圆角效果处理实现
class ClipDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('clip demo'),
      ),
      body: Container(
        alignment: Alignment.center,
        margin: EdgeInsets.all(20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('BoxDecoration 圆角'),
            Container(
              width: 100,
              height: 100,
              decoration: BoxDecoration(
                color: Colors.yellow,
                borderRadius: BorderRadius.all(Radius.elliptical(80.0, 25.0)),
              ),
            ),
            SizedBox(
              height: 10,
            ),
            Text("BoxDecoration 圆角对 child"),
            Container(
              width: 100,
              height: 100,
              decoration: BoxDecoration(
                color: Colors.red,
                borderRadius: BorderRadius.all(
                  Radius.circular(5.0),
                ),
              ),
              child: Container(
                color: Colors.cyan,
                width: 100,
                height: 100,
              ),
            ),
            SizedBox(
              height: 10,
            ),
            Text('ClipRRect 圆角对 child'),
            ClipRRect(
              borderRadius: BorderRadius.all(
                Radius.circular(5.0),
              ),
              child: Container(
                color: Colors.blue,
                width: 100,
                height: 100,
              ),
            )
          ],
        ),
      ),
    );
  }
}
